Skip to contentSkip to conversation

CUPS plugin discovery bits

Bluez-devel Bastien Nocera 5 participants 21 messages May 23, 2007 – Jun 7, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Heya,

Here's a patch against CVS bluez-utils to add discovery to the CUPS backend. With this, it means that most CUPS front-end will be able to list visible printers when adding a new one, be it through the web interface or other front-ends (like Fedora' system-config-printer).

It adds D-Bus and glib as dependencies for the backend (not that it matters that much...).

There are 2 things left:
- First, printer model/make detection. Does anyone know how this works over HCRP or SPP? I would think that it would be something accessible over HCRP as some other OSes are able to autodetect the necessary printer driver (IEEE1284?).
Links to the specs appreciated.
- Secondly, does this detection require the devices to be paired? If it does, then I'd want to add something like "--identify" to the bluetooth backend so that front-ends can get make/model _after_ the printer has been added to the queues and paired (if we did this during discovery we might get flooded in auths).

Comments welcome.

Cheers

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: acinclude.m4
===================================================================
RCS file: /cvsroot/bluez/utils/acinclude.m4,v
retrieving revision 1.107

acinclude.m4 +2 -0
diff -u -p -r1.107 acinclude.m4
@@ -78,6 +78,8 @@ AC_DEFUN([AC_PATH_GLIB], [
 	PKG_CHECK_MODULES(GLIB, glib-2.0, glib_found=yes, glib_found=no)
 	AC_SUBST(GLIB_CFLAGS)
 	AC_SUBST(GLIB_LIBS)
+	GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
+	AC_SUBST(GLIB_GENMARSHAL)
 ])
 
 AC_DEFUN([AC_PATH_DBUS], [

Index: cups/Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/cups/Makefile.am,v
retrieving revision 1.9

Makefile.am +14 -4
diff -u -p -r1.9 Makefile.am
@@ -7,9 +7,19 @@ else
 noinst_PROGRAMS = bluetooth
 endif
 
-bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c
-bluetooth_LDADD = @BLUEZ_LIBS@
+MARSHAL_FILES = bluez-cups-marshal.h bluez-cups-marshal.c
 
-AM_CFLAGS = @BLUEZ_CFLAGS@
+bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c $(MARSHAL_FILES)
+bluetooth_LDADD = @DBUS_GLIB_LIBS@ @BLUEZ_LIBS@
 
-MAINTAINERCLEANFILES = Makefile.in
+bluez-cups-marshal.h: bluez-cups-marshal.list
+	$(GLIB_GENMARSHAL) --prefix=bluez_cups_marshal $< --header > $@
+bluez-cups-marshal.c: bluez-cups-marshal.list
+	$(GLIB_GENMARSHAL) --prefix=bluez_cups_marshal $< --body > $@
+main.c: $(MARSHAL_FILES)
+
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_GLIB_CFLAGS@
+
+MAINTAINERCLEANFILES = Makefile.in $(MARSHAL_FILES)
+CLEANFILES = $(MARSHAL_FILES)
+EXTRA_DIST = bluez-cups-marshal.list

Index: cups/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/cups/main.c,v
retrieving revision 1.6

main.c +246 -1

265 lines not on this page · raw message

bluez-cups-marshal.list new file +2 -0
@@ -0,0 +1,2 @@
+VOID:STRING,UINT,INT
+VOID:STRING,STRING

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#1 lore raw

Hi Bastien,

Quoted 7 lines

Here's a patch against CVS bluez-utils to add discovery to the CUPS backend. With this, it means that most CUPS front-end will be able to list visible printers when adding a new one, be it through the web interface or other front-ends (like Fedora' system-config-printer).

It adds D-Bus and glib as dependencies for the backend (not that it matters that much...).

it actually does. We provide an eGlib for embedded systems and so when compiled with GLib, we only use that function subset.

And second you use the GLib D-Bus bindings. I am not willing to create these dependencies for a "daemon" package.

Another small thing is that DisocverDevices() will automatically take care of the name resolving for you. So no need to call GetRemoteName(). You will get the RemoteNameUpdated() signal.

The thing that worries me is when you start CUPS it will list through all backends and make them list. So on every boot the system will scan for devices in range and that can slow down the system boot. So this might not be a good idea. Actually that is the reason why we wanna go for a printing service in the future.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw
Quoted 5 lines · Marcel Holtmann

The thing that worries me is when you start CUPS it will list through all backends and make them list. So on every boot the system will scan for devices in range and that can slow down the system boot. So this might not be a good idea. Actually that is the reason why we wanna go for a printing service in the future.

This hasn't been true since CUPS 1.1.x. In CUPS 1.2.x device discovery is performed on demand.

Tim.
*/

#3 lore raw
In reply to Marcel Holtmann
Quoted 7 lines · Marcel Holtmann

Hi Bastien,

Quoted 5 lines

Here's a patch against CVS bluez-utils to add discovery to the CUPS backend. With this, it means that most CUPS front-end will be able to list visible printers when adding a new one, be it through the web interface or other front-ends (like Fedora' system-config-printer).

Quoted 8 lines
Quoted 2 lines

It adds D-Bus and glib as dependencies for the backend (not that it matters that much...).

it actually does. We provide an eGlib for embedded systems and so when compiled with GLib, we only use that function subset.

And second you use the GLib D-Bus bindings. I am not willing to create these dependencies for a "daemon" package.

It's not a "daemon", as in, it won't be running all the time. It's only a small short-lived program. Should I make it compile-time dependency?

Quoted 3 lines

Another small thing is that DisocverDevices() will automatically take care of the name resolving for you. So no need to call GetRemoteName(). You will get the RemoteNameUpdated() signal.

Cool, I'll clean up the code.

Quoted 5 lines

The thing that worries me is when you start CUPS it will list through all backends and make them list. So on every boot the system will scan for devices in range and that can slow down the system boot. So this might not be a good idea. Actually that is the reason why we wanna go for a printing service in the future.

As Tim mentioned, CUPS won't do the requests on startup, but on demand.

As for the printing service, what would it actually buy us, ie. which feature would you have in it that aren't possible in the backend?

Signature · 12 lines
Bastien Nocera <[email protected]> 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
#4 lore raw
Quoted 1 line · Bastien Nocera

On Wed, 2007-05-23 at 17:51 +0200, Marcel Holtmann wrote:

<snip>

Quoted 5 lines
Quoted 3 lines

Another small thing is that DisocverDevices() will automatically take care of the name resolving for you. So no need to call GetRemoteName(). You will get the RemoteNameUpdated() signal.

Cool, I'll clean up the code.

Updated patch attached.

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: acinclude.m4
===================================================================
RCS file: /cvsroot/bluez/utils/acinclude.m4,v
retrieving revision 1.107

acinclude.m4 +2 -0
diff -u -p -r1.107 acinclude.m4
@@ -78,6 +78,8 @@ AC_DEFUN([AC_PATH_GLIB], [
 	PKG_CHECK_MODULES(GLIB, glib-2.0, glib_found=yes, glib_found=no)
 	AC_SUBST(GLIB_CFLAGS)
 	AC_SUBST(GLIB_LIBS)
+	GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
+	AC_SUBST(GLIB_GENMARSHAL)
 ])
 
 AC_DEFUN([AC_PATH_DBUS], [

Index: cups/Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/cups/Makefile.am,v
retrieving revision 1.9

Makefile.am +14 -4
diff -u -p -r1.9 Makefile.am
@@ -7,9 +7,19 @@ else
 noinst_PROGRAMS = bluetooth
 endif
 
-bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c
-bluetooth_LDADD = @BLUEZ_LIBS@
+MARSHAL_FILES = bluez-cups-marshal.h bluez-cups-marshal.c
 
-AM_CFLAGS = @BLUEZ_CFLAGS@
+bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c $(MARSHAL_FILES)
+bluetooth_LDADD = @DBUS_GLIB_LIBS@ @BLUEZ_LIBS@
 
-MAINTAINERCLEANFILES = Makefile.in
+bluez-cups-marshal.h: bluez-cups-marshal.list
+	$(GLIB_GENMARSHAL) --prefix=bluez_cups_marshal $< --header > $@
+bluez-cups-marshal.c: bluez-cups-marshal.list
+	$(GLIB_GENMARSHAL) --prefix=bluez_cups_marshal $< --body > $@
+main.c: $(MARSHAL_FILES)
+
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_GLIB_CFLAGS@
+
+MAINTAINERCLEANFILES = Makefile.in $(MARSHAL_FILES)
+CLEANFILES = $(MARSHAL_FILES)
+EXTRA_DIST = bluez-cups-marshal.list

Index: cups/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/cups/main.c,v
retrieving revision 1.6

main.c +238 -1

257 lines not on this page · raw message

bluez-cups-marshal.list new file +2 -0
@@ -0,0 +1,2 @@
+VOID:STRING,UINT,INT
+VOID:STRING,STRING

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#5 lore raw

Hi Bastien,

Quoted 1 line · Bastien Nocera

Updated patch attached.

A little about optimizing the device discovery. It seems you are filtering out all non-printer devices by checking the minor device class but still requesting names for all found devices (actually hcid is doing the requesting because you use the normal DiscoverDevices method).

The name requests are the most time wasting operations of the device discovery process (if a device happens to go out of range you'll have to wait usually between 10 and 20 seconds for a page timeout to occur, and even if it is within range we're talking about several seconds usually for the name request to succeed). To allow overcoming this issue have the DiscoverDevicesWithoutNameResolving method which can be used when you can deduce from the device class information whether you want to ignore the device or get further information about it (e.g. its name, provided services through SDP, etc).

So, for the CUPS case, the optimal solution would be to use this alternate discovery method and for each RemoteDeviceFound signal check the class of device value and if it matches request the name for the device (as you were doing in your first patch). This way time will not go wasted to requesting names for devices we will not do anything with anyway.

Johan

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#6 lore raw
Quoted 6 lines · Johan Hedberg

Hi Bastien,

Quoted 1 line · Bastien Nocera

Updated patch attached.

A little about optimizing the device discovery.

<snip>

Quoted 3 lines

This way time
will not go wasted to requesting names for devices we will not do anything with anyway.

Good call. I'll fix it up tomorrow.

Signature · 12 lines
Bastien Nocera <[email protected]> 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
#7 lore raw
In reply to Johan Hedberg
Quoted 6 lines · Johan Hedberg

Hi Bastien,

Quoted 1 line · Bastien Nocera

Updated patch attached.

A little about optimizing the device discovery.

Fixed in this version, and also added recent devices (through ListRemoteDevices and ListBondings).

Marcel told me this would be mergeable if I removed the dbus-glib dependency, which I'm going to do now.

Cheers

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: acinclude.m4
===================================================================
RCS file: /cvsroot/bluez/utils/acinclude.m4,v
retrieving revision 1.107

acinclude.m4 +2 -0
diff -u -p -r1.107 acinclude.m4
@@ -78,6 +78,8 @@ AC_DEFUN([AC_PATH_GLIB], [
 	PKG_CHECK_MODULES(GLIB, glib-2.0, glib_found=yes, glib_found=no)
 	AC_SUBST(GLIB_CFLAGS)
 	AC_SUBST(GLIB_LIBS)
+	GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
+	AC_SUBST(GLIB_GENMARSHAL)
 ])
 
 AC_DEFUN([AC_PATH_DBUS], [

Index: cups/Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/cups/Makefile.am,v
retrieving revision 1.9

Makefile.am +14 -4
diff -u -p -r1.9 Makefile.am
@@ -7,9 +7,19 @@ else
 noinst_PROGRAMS = bluetooth
 endif
 
-bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c
-bluetooth_LDADD = @BLUEZ_LIBS@
+MARSHAL_FILES = bluez-cups-marshal.h bluez-cups-marshal.c
 
-AM_CFLAGS = @BLUEZ_CFLAGS@
+bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c $(MARSHAL_FILES)
+bluetooth_LDADD = @DBUS_GLIB_LIBS@ @BLUEZ_LIBS@
 
-MAINTAINERCLEANFILES = Makefile.in
+bluez-cups-marshal.h: bluez-cups-marshal.list
+	$(GLIB_GENMARSHAL) --prefix=bluez_cups_marshal $< --header > $@
+bluez-cups-marshal.c: bluez-cups-marshal.list
+	$(GLIB_GENMARSHAL) --prefix=bluez_cups_marshal $< --body > $@
+main.c: $(MARSHAL_FILES)
+
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_GLIB_CFLAGS@
+
+MAINTAINERCLEANFILES = Makefile.in $(MARSHAL_FILES)
+CLEANFILES = $(MARSHAL_FILES)
+EXTRA_DIST = bluez-cups-marshal.list

Index: cups/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/cups/main.c,v
retrieving revision 1.6

main.c +306 -1

325 lines not on this page · raw message

bluez-cups-marshal.list new file +2 -0
@@ -0,0 +1,2 @@
+VOID:STRING,UINT,INT
+VOID:STRING,STRING

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#8 lore raw

Hi Bastien,

Quoted 10 lines · Bastien Nocera
Quoted 6 lines · Johan Hedberg

Hi Bastien,

Quoted 1 line · Bastien Nocera

Updated patch attached.

A little about optimizing the device discovery.

Fixed in this version, and also added recent devices (through ListRemoteDevices and ListBondings).

I see you're now using the manual name resolving discovery and deciding from the device class whether to get the name or not. Great! However, you are causing an unecessary roundtrip back to hcid by calling GetRemoteMinorClass because you in fact already have the necessary information encoded in the class parameter of the RemoteDeviceFound signal. It's not as convenient as a string to do a strcmp on, but you can just take example from hcid code how it converts the 3 byte value to the string.

Johan

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#9 lore raw
Quoted 14 lines · Johan Hedberg

Hi Bastien,

Quoted 10 lines · Bastien Nocera
Quoted 6 lines · Johan Hedberg

Hi Bastien,

Quoted 1 line · Bastien Nocera

Updated patch attached.

A little about optimizing the device discovery.

Fixed in this version, and also added recent devices (through ListRemoteDevices and ListBondings).

Quoted 8 lines

I see you're now using the manual name resolving discovery and deciding from the device class whether to get the name or not. Great! However, you are causing an unecessary roundtrip back to hcid by calling GetRemoteMinorClass because you in fact already have the necessary information encoded in the class parameter of the RemoteDeviceFound signal. It's not as convenient as a string to do a strcmp on, but you can just take example from hcid code how it converts the 3 byte value to the string.

This is most ugly. There should really be a helper function for that, or hcid should pass a decoded argument.

Anyway, it's implemented now, along with a port to pure D-Bus, and can use the builtin eglib instead of the system one.

Marcel

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: cups/Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/cups/Makefile.am,v
retrieving revision 1.9

Makefile.am +3 -2
diff -u -p -r1.9 Makefile.am
@@ -8,8 +8,9 @@ noinst_PROGRAMS = bluetooth
 endif
 
 bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c
-bluetooth_LDADD = @BLUEZ_LIBS@
+bluetooth_LDADD = @DBUS_LIBS@ @GLIB_LIBS@ @BLUEZ_LIBS@ $(top_builddir)/common/libhelper.a
 
-AM_CFLAGS = @BLUEZ_CFLAGS@
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ -I$(top_srcdir)/common
 
 MAINTAINERCLEANFILES = Makefile.in
+

Index: cups/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/cups/main.c,v
retrieving revision 1.6

main.c +403 -1

422 lines not on this page · raw message

Index: eglib/gmain.c
===================================================================
RCS file: /cvsroot/bluez/utils/eglib/gmain.c,v
retrieving revision 1.27

gmain.c +42 -0

48 lines not on this page · raw message

Index: eglib/gmain.h
===================================================================
RCS file: /cvsroot/bluez/utils/eglib/gmain.h,v
retrieving revision 1.12

gmain.h +1 -0
diff -u -p -r1.12 gmain.h
@@ -191,6 +191,7 @@ int g_slist_length(GSList *list);
 
 void g_slist_foreach(GSList *list, GFunc func, void *user_data);
 void g_slist_free(GSList *list);
+GSList *g_slist_delete_link (GSList *list, GSList *link);
 
 /* End GSList declarations */
 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#10 lore raw

On Thu, 2007-05-24 at 19:50 +0100, Bastien Nocera wrote:
<snip>

Quoted 5 lines

This is most ugly. There should really be a helper function for that, or hcid should pass a decoded argument.

Anyway, it's implemented now, along with a port to pure D-Bus, and can use the builtin eglib instead of the system one.

And an updated version which pulls the IEEE1284 ID from the attributes of the SDP record. This means that it takes 2 clicks in most config tools to add the printer (add printer, and select the bluetooth printer).

If you're using the system hcid instead of the patched in bluez-utils, you'll need to replace the line:
const char *svc_id = "hcrp"; /* aka 0x1126 */
with:
const char *svc_id = "00001126-0000-1000-8000-00805F9B34FB"; in cups/main.c device_get_ieee1284_id()

Patch attached.

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: cups/Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/cups/Makefile.am,v
retrieving revision 1.9

Makefile.am +7 -2
diff -u -p -r1.9 Makefile.am
@@ -8,8 +8,13 @@ noinst_PROGRAMS = bluetooth
 endif
 
 bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c
-bluetooth_LDADD = @BLUEZ_LIBS@
+if EXPAT
+bluetooth_LDADD = @DBUS_LIBS@ @GLIB_LIBS@ @BLUEZ_LIBS@ -lexpat $(top_builddir)/common/libhelper.a
+else
+bluetooth_LDADD = @DBUS_LIBS@ @GLIB_LIBS@ @BLUEZ_LIBS@ $(top_builddir)/common/libhelper.a
+endif
 
-AM_CFLAGS = @BLUEZ_CFLAGS@
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@
 
 MAINTAINERCLEANFILES = Makefile.in
+

Index: cups/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/cups/main.c,v
retrieving revision 1.6

main.c +506 -1

525 lines not on this page · raw message

Index: eglib/gmain.c
===================================================================
RCS file: /cvsroot/bluez/utils/eglib/gmain.c,v
retrieving revision 1.27

gmain.c +42 -0

48 lines not on this page · raw message

Index: eglib/gmain.h
===================================================================
RCS file: /cvsroot/bluez/utils/eglib/gmain.h,v
retrieving revision 1.12

gmain.h +1 -0
diff -u -p -r1.12 gmain.h
@@ -191,6 +191,7 @@ int g_slist_length(GSList *list);
 
 void g_slist_foreach(GSList *list, GFunc func, void *user_data);
 void g_slist_free(GSList *list);
+GSList *g_slist_delete_link (GSList *list, GSList *link);
 
 /* End GSList declarations */
 

Index: hcid/dbus-sdp.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-sdp.c,v
retrieving revision 1.71

dbus-sdp.c +1 -0
diff -u -p -r1.71 dbus-sdp.c
@@ -270,6 +270,7 @@ sdp_service_t sdp_service[] = {
 	{ "fax",	FAX_SVCLASS_ID,			"Fax"			},
 	{ "spp",	SERIAL_PORT_SVCLASS_ID,		"Serial Port"		},
 	{ "hsp",	HEADSET_SVCLASS_ID,		"Headset"		},
+	{ "hcrp",	HCR_PRINT_SVCLASS_ID,		"Hardcopy Cable Replacement (Printer)" },
 	{ NULL }
 };
 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#11 lore raw
Quoted 13 lines · Bastien Nocera

On Thu, 2007-05-24 at 19:50 +0100, Bastien Nocera wrote:
<snip>

Quoted 5 lines

This is most ugly. There should really be a helper function for that, or hcid should pass a decoded argument.

Anyway, it's implemented now, along with a port to pure D-Bus, and can use the builtin eglib instead of the system one.

And an updated version which pulls the IEEE1284 ID from the attributes of the SDP record. This means that it takes 2 clicks in most config tools to add the printer (add printer, and select the bluetooth printer).

Quoted 8 lines

If you're using the system hcid instead of the patched in bluez-utils, you'll need to replace the line:
const char *svc_id = "hcrp"; /* aka 0x1126 */
with:
const char *svc_id = "00001126-0000-1000-8000-00805F9B34FB"; in cups/main.c device_get_ieee1284_id()

Patch attached.

With some indentation changes, at Marcel's request.

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: cups/Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/cups/Makefile.am,v
retrieving revision 1.9

Makefile.am +7 -2
diff -u -p -r1.9 Makefile.am
@@ -8,8 +8,13 @@ noinst_PROGRAMS = bluetooth
 endif
 
 bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c
-bluetooth_LDADD = @BLUEZ_LIBS@
+if EXPAT
+bluetooth_LDADD = @DBUS_LIBS@ @GLIB_LIBS@ @BLUEZ_LIBS@ -lexpat $(top_builddir)/common/libhelper.a
+else
+bluetooth_LDADD = @DBUS_LIBS@ @GLIB_LIBS@ @BLUEZ_LIBS@ $(top_builddir)/common/libhelper.a
+endif
 
-AM_CFLAGS = @BLUEZ_CFLAGS@
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@
 
 MAINTAINERCLEANFILES = Makefile.in
+

Index: cups/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/cups/main.c,v
retrieving revision 1.6

main.c +490 -1

509 lines not on this page · raw message

Index: eglib/gmain.c
===================================================================
RCS file: /cvsroot/bluez/utils/eglib/gmain.c,v
retrieving revision 1.27

gmain.c +42 -0

48 lines not on this page · raw message

Index: eglib/gmain.h
===================================================================
RCS file: /cvsroot/bluez/utils/eglib/gmain.h,v
retrieving revision 1.12

gmain.h +1 -0
diff -u -p -r1.12 gmain.h
@@ -191,6 +191,7 @@ int g_slist_length(GSList *list);
 
 void g_slist_foreach(GSList *list, GFunc func, void *user_data);
 void g_slist_free(GSList *list);
+GSList *g_slist_delete_link (GSList *list, GSList *link);
 
 /* End GSList declarations */
 

Index: hcid/dbus-sdp.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-sdp.c,v
retrieving revision 1.71

dbus-sdp.c +1 -0
diff -u -p -r1.71 dbus-sdp.c
@@ -270,6 +270,7 @@ sdp_service_t sdp_service[] = {
 	{ "fax",	FAX_SVCLASS_ID,			"Fax"			},
 	{ "spp",	SERIAL_PORT_SVCLASS_ID,		"Serial Port"		},
 	{ "hsp",	HEADSET_SVCLASS_ID,		"Headset"		},
+	{ "hcrp",	HCR_PRINT_SVCLASS_ID,		"Hardcopy Cable Replacement (Printer)" },
 	{ NULL }
 };
 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#12 lore raw
Quoted 21 lines · Bastien Nocera
Quoted 20 lines · Bastien Nocera

On Thu, 2007-05-24 at 19:50 +0100, Bastien Nocera wrote:
<snip>

Quoted 5 lines

This is most ugly. There should really be a helper function for that, or hcid should pass a decoded argument.

Anyway, it's implemented now, along with a port to pure D-Bus, and can use the builtin eglib instead of the system one.

And an updated version which pulls the IEEE1284 ID from the attributes of the SDP record. This means that it takes 2 clicks in most config tools to add the printer (add printer, and select the bluetooth printer).

If you're using the system hcid instead of the patched in bluez-utils, you'll need to replace the line:
const char *svc_id = "hcrp"; /* aka 0x1126 */
with:
const char *svc_id = "00001126-0000-1000-8000-00805F9B34FB"; in cups/main.c device_get_ieee1284_id()

Quoted 3 lines
Quoted 1 line

Patch attached.

With some indentation changes, at Marcel's request.

- Don't typedef BluezCupsDevice
- Fix includes from common/
- Simplify Makefile.am slightly
- Remove already committed eglib changes

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: cups/Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/cups/Makefile.am,v
retrieving revision 1.9

Makefile.am +7 -2
diff -u -p -r1.9 Makefile.am
@@ -8,8 +8,13 @@ noinst_PROGRAMS = bluetooth
 endif
 
 bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c
-bluetooth_LDADD = @BLUEZ_LIBS@
+bluetooth_LDADD = @DBUS_LIBS@ @GLIB_LIBS@ @BLUEZ_LIBS@ $(top_builddir)/common/libhelper.a
 
-AM_CFLAGS = @BLUEZ_CFLAGS@
+if EXPAT
+bluetooth_LDADD += -lexpat
+endif
+
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ -I$(top_srcdir)/common/
 
 MAINTAINERCLEANFILES = Makefile.in
+

Index: cups/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/cups/main.c,v
retrieving revision 1.6

main.c +491 -1

510 lines not on this page · raw message

Index: hcid/dbus-sdp.c
===================================================================
RCS file: /cvsroot/bluez/utils/hcid/dbus-sdp.c,v
retrieving revision 1.74

dbus-sdp.c +1 -0
diff -u -p -r1.74 dbus-sdp.c
@@ -284,6 +284,7 @@ sdp_service_t sdp_service[] = {
 	{ "fax",	FAX_SVCLASS_ID,			"Fax"			},
 	{ "spp",	SERIAL_PORT_SVCLASS_ID,		"Serial Port"		},
 	{ "hsp",	HEADSET_SVCLASS_ID,		"Headset"		},
+	{ "hcrp",	HCR_PRINT_SVCLASS_ID,		"Hardcopy Cable Replacement (Printer)" },
 	{ NULL }
 };
 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#13 lore raw

I consider this as a wizard for printers, like in NetwokManager the network wizard also
does start a discovery and it work like a charm but in my opinion it doesnt belong to bluez utils.

Having each wizard to rely in its own discovery is probably a bad design, we can probably integrate
all wizard together and then having services configuring them in the background. This way we
could leave to the user to use periodic scan and popup specific device wizard dependent on
each service when active. Also in my opinion it should exist a printer service for those that want to
configure its devices that are not in discoverable mode.

Btw, The printer wizard as it is now wont work with periodic discovery, signals DiscoveryStarted and
DiscoveryCompleted are not emitted while in periodic discovery.

Quoted 49 lines · Bastien Nocera
Quoted 4 lines · Bastien Nocera
Quoted 3 lines · Bastien Nocera

On Thu, 2007-05-24 at 19:50 +0100, Bastien Nocera wrote:
<snip>

Quoted 1 line

This is most ugly. There should really be a helper function for

that, or

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

hcid should pass a decoded argument.

Anyway, it's implemented now, along with a port to pure D-Bus, and

can

Quoted 14 lines
Quoted 14 lines
Quoted 1 line

use the builtin eglib instead of the system one.

And an updated version which pulls the IEEE1284 ID from the attributes of the SDP record. This means that it takes 2 clicks in most config tools to add the printer (add printer, and select the bluetooth printer).

If you're using the system hcid instead of the patched in bluez-utils, you'll need to replace the line:
const char *svc_id = "hcrp"; /* aka 0x1126 */
with:
const char *svc_id = "00001126-0000-1000-8000-00805F9B34FB"; in cups/main.c device_get_ieee1284_id()

Quoted 3 lines
Quoted 1 line

Patch attached.

With some indentation changes, at Marcel's request.

- Don't typedef BluezCupsDevice
- Fix includes from common/
- Simplify Makefile.am slightly
- Remove already committed eglib changes

--
Bastien Nocera <[email protected]>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

Signature · 2 lines
Luiz Augusto von Dentz
Engenheiro de Computação

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#14 lore raw
Quoted 4 lines · Luiz Augusto von Dentz

I consider this as a wizard for printers, like in NetwokManager the network wizard also
does start a discovery and it work like a charm but in my opinion it doesnt belong to bluez utils.

It's a standard feature of cups backends. If they support it, they should list the accessible/known printers in the vicinity.

Quoted 9 lines

Having each wizard to rely in its own discovery is probably a bad design, we can probably integrate
all wizard together and then having services configuring them in the background. This way we
could leave to the user to use periodic scan and popup specific device wizard dependent on
each service when active. Also in my opinion it should exist a printer service for those that want to
configure its devices that are not in discoverable mode.

True, it would be much better. But in the meanwhile, this patch simply implements a CUPS feature and allows us to have some basic integration in the distribution-provided printer tools.

Being able to configure the printer via a bluetooth configuration wizard requires a bit more work, but it's also on my plans. There should be a CUPS service that would allow hcid to add/remove bluetooth printers from cups with minimum user interaction.

Quoted 3 lines

Btw, The printer wizard as it is now wont work with periodic discovery, signals DiscoveryStarted and DiscoveryCompleted are not emitted while in periodic discovery.

The cups backend isn't supposed to run forever, so it can't do periodic discovery.

Signature · 12 lines
Bastien Nocera <[email protected]> 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
#15 lore raw

Comments in line:

Quoted 20 lines · Bastien Nocera
Quoted 4 lines · Luiz Augusto von Dentz

I consider this as a wizard for printers, like in NetwokManager the network wizard also
does start a discovery and it work like a charm but in my opinion it doesnt belong to bluez utils.

It's a standard feature of cups backends. If they support it, they should list the accessible/known printers in the vicinity.

Quoted 9 lines

Having each wizard to rely in its own discovery is probably a bad design, we can probably integrate
all wizard together and then having services configuring them in the background. This way we
could leave to the user to use periodic scan and popup specific device wizard dependent on
each service when active. Also in my opinion it should exist a printer service for those that want to
configure its devices that are not in discoverable mode.

Quoted 3 lines

True, it would be much better. But in the meanwhile, this patch simply implements a CUPS feature and allows us to have some basic integration in the distribution-provided printer tools.

So we may mark this as subject to change.

Being able to configure the printer via a bluetooth configuration wizard

Quoted 3 lines

requires a bit more work, but it's also on my plans. There should be a CUPS service that would allow hcid to add/remove bluetooth printers from cups with minimum user interaction.

My idea is to have printer service more generic, the bluetooth wizard could do
CUPS integration as it would integrate with any other system wide integration.

Quoted 6 lines

Btw, The printer wizard as it is now wont work with periodic

Quoted 2 lines

discovery, signals DiscoveryStarted and DiscoveryCompleted are not emitted while in periodic discovery.

The cups backend isn't supposed to run forever, so it can't do periodic discovery.

Well that is not the case of being running forever but you could probably test if the periodic scan is active before you start a blocking discovery. My main concern is about multiple process doing this, the probability of having collisions while doing sdp searches could be very high as it is very common to have more than one functionality in a device, this leaves wizard processes very complicated and may force them to reschedule on each collision .

--

Quoted 13 lines

Bastien Nocera <[email protected]>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

Signature · 2 lines
Luiz Augusto von Dentz
Engenheiro de Computação

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#16 lore raw

Hi Luiz,

Quoted 9 lines

> Btw, The printer wizard as it is now wont work with periodic > discovery, signals DiscoveryStarted and
> DiscoveryCompleted are not emitted while in periodic discovery.

The cups backend isn't supposed to run forever, so it can't do periodic
discovery.

Quoted 12 lines

Well that is not the case of being running forever but you could probably
test if the periodic scan is active before you start a blocking discovery.
My main concern is about multiple process doing this, the probability of
having collisions while doing sdp searches could be very high as it is very
common to have more than one functionality in a device, this leaves wizard
processes very complicated and may force them to reschedule on each collision .

it is fine to start an inquiry while you are in periodic inquiry. With the exception that some chips don't allow that.

It is also fine to create an ACL link while in periodic inquiry since the device then will stop its inquiry train automatically and switch to page for the ACL link. After it it will continue with the periodic inquiry as before.

The kernel now takes care of serializing the ACL link creation. This works perfectly fine. There is one small glitch with remote name resolve that doesn't trigger the ACL queue. However real name request have been always a problem. However over D-Bus you only get cached names or an error anyway. The only exception is if you in inquiry or periodic inquiry. While the inquiry is no problem, we have to check with the periodic inquiry if we create a deadlock.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#17 lore raw
In reply to Bastien Nocera

Hi Bastien,

Quoted 6 lines
Quoted 1 line

With some indentation changes, at Marcel's request.

- Don't typedef BluezCupsDevice
- Fix includes from common/
- Simplify Makefile.am slightly
- Remove already committed eglib changes

with some fixes and cleanups, the has now been committed to the CVS.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#18 lore raw
Quoted 10 lines · Marcel Holtmann

Hi Bastien,

Quoted 6 lines
Quoted 1 line

With some indentation changes, at Marcel's request.

- Don't typedef BluezCupsDevice
- Fix includes from common/
- Simplify Makefile.am slightly
- Remove already committed eglib changes

with some fixes and cleanups, the has now been committed to the CVS.

Great stuff, thanks!

Signature · 12 lines
Bastien Nocera <[email protected]> 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel
#19 lore raw
In reply to Marcel Holtmann
Quoted 7 lines · Marcel Holtmann

Hi Bastien,

Quoted 5 lines

Here's a patch against CVS bluez-utils to add discovery to the CUPS backend. With this, it means that most CUPS front-end will be able to list visible printers when adding a new one, be it through the web interface or other front-ends (like Fedora' system-config-printer).

Quoted 8 lines
Quoted 2 lines

It adds D-Bus and glib as dependencies for the backend (not that it matters that much...).

it actually does. We provide an eGlib for embedded systems and so when compiled with GLib, we only use that function subset.

And second you use the GLib D-Bus bindings. I am not willing to create these dependencies for a "daemon" package.

The dependency is already optional (and if not, I can make it so).

I've looked at what using dbus directly would entail, and I'm not sure that's a good use of my (or anyone's) time. The code would be much more complicated than it would need to be, and certainly not any more readable.

In the worst case, how about moving the cups plugin to another module?

Quoted 2 lines

Actually that is the reason why we wanna go
for a printing service in the future.

I still haven't heard the benefits, or features that service would have.

Unless you want to pass data from a client, over dbus to this printing service, which I don't think is a good idea given the potential size of the data being passed over.

If anyone is involved with that, a draft API would be appreciated.

This latest patch avoids untranslated messages getting to the end-user.

Cheers

Signature · 1 line
Bastien Nocera <[email protected]> 

Index: acinclude.m4
===================================================================
RCS file: /cvsroot/bluez/utils/acinclude.m4,v
retrieving revision 1.107

acinclude.m4 +2 -0
diff -u -p -r1.107 acinclude.m4
@@ -78,6 +78,8 @@ AC_DEFUN([AC_PATH_GLIB], [
 	PKG_CHECK_MODULES(GLIB, glib-2.0, glib_found=yes, glib_found=no)
 	AC_SUBST(GLIB_CFLAGS)
 	AC_SUBST(GLIB_LIBS)
+	GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
+	AC_SUBST(GLIB_GENMARSHAL)
 ])
 
 AC_DEFUN([AC_PATH_DBUS], [

Index: cups/Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/cups/Makefile.am,v
retrieving revision 1.9

Makefile.am +14 -4
diff -u -p -r1.9 Makefile.am
@@ -7,9 +7,19 @@ else
 noinst_PROGRAMS = bluetooth
 endif
 
-bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c
-bluetooth_LDADD = @BLUEZ_LIBS@
+MARSHAL_FILES = bluez-cups-marshal.h bluez-cups-marshal.c
 
-AM_CFLAGS = @BLUEZ_CFLAGS@
+bluetooth_SOURCES = main.c sdp.c spp.c hcrp.c $(MARSHAL_FILES)
+bluetooth_LDADD = @DBUS_GLIB_LIBS@ @BLUEZ_LIBS@
 
-MAINTAINERCLEANFILES = Makefile.in
+bluez-cups-marshal.h: bluez-cups-marshal.list
+	$(GLIB_GENMARSHAL) --prefix=bluez_cups_marshal $< --header > $@
+bluez-cups-marshal.c: bluez-cups-marshal.list
+	$(GLIB_GENMARSHAL) --prefix=bluez_cups_marshal $< --body > $@
+main.c: $(MARSHAL_FILES)
+
+AM_CFLAGS = @BLUEZ_CFLAGS@ @DBUS_GLIB_CFLAGS@
+
+MAINTAINERCLEANFILES = Makefile.in $(MARSHAL_FILES)
+CLEANFILES = $(MARSHAL_FILES)
+EXTRA_DIST = bluez-cups-marshal.list

Index: cups/main.c
===================================================================
RCS file: /cvsroot/bluez/utils/cups/main.c,v
retrieving revision 1.6

main.c +302 -1

321 lines not on this page · raw message

bluez-cups-marshal.list new file +2 -0
@@ -0,0 +1,2 @@
+VOID:STRING,UINT,INT
+VOID:STRING,STRING

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#20 lore raw

Hi Bastien,

Quoted 14 lines
Quoted 5 lines
Quoted 5 lines

Here's a patch against CVS bluez-utils to add discovery to the CUPS backend. With this, it means that most CUPS front-end will be able to list visible printers when adding a new one, be it through the web interface or other front-ends (like Fedora' system-config-printer).

Quoted 8 lines
Quoted 2 lines

It adds D-Bus and glib as dependencies for the backend (not that it matters that much...).

it actually does. We provide an eGlib for embedded systems and so when compiled with GLib, we only use that function subset.

And second you use the GLib D-Bus bindings. I am not willing to create these dependencies for a "daemon" package.

Quoted 6 lines

The dependency is already optional (and if not, I can make it so).

I've looked at what using dbus directly would entail, and I'm not sure that's a good use of my (or anyone's) time. The code would be much more complicated than it would need to be, and certainly not any more readable.

you can use a lot of helpers from common/libhelper.a to make the integration with D-Bus really simple. Of course low-level code might is a little bit more complex, but for me it is not less readable actually.

Quoted 1 line

In the worst case, how about moving the cups plugin to another module?

I am not maintaining another package.

Quoted 10 lines
Quoted 2 lines

Actually that is the reason why we wanna go
for a printing service in the future.

I still haven't heard the benefits, or features that service would have.

Unless you want to pass data from a client, over dbus to this printing service, which I don't think is a good idea given the potential size of the data being passed over.

If anyone is involved with that, a draft API would be appreciated.

We are not at that point. It was an idea that came of at the last BlueZ developer meeting. However it might be bogus and we don't do it. I can tell you more once we actually do start working on it. So no real details on it so far.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel